Golangの開発環境用のDev Containersを作る
Dev Containers is 何?
https://scrapbox.io/files/63ba4afe1635f0001d345648.png
Developing inside a Container using Visual Studio Code Remote Development
ホストに立ち上げたコンテナ内でVSCodeを使った開発環境を作るやつ
何が嬉しいか
ホスト側の環境を汚さない
ホスト側の環境に寄らずに開発環境を作れる
今回作ったGolang用のDev Container環境
これ
YuheiNakasaka/go-dev-containers-template
下記のリポジトリを参考にした
microsoft/vscode-remote-try-go: Go sample project for trying out Dev Containers
microsoft/vscode-dev-containers
devcontainers/images: Repository for pre-built dev container images published under mcr.microsoft.com/devcontainers
devcontainers
project-layout/README_ja.md at master · golang-standards/project-layout
想定用途
web開発
CLIなどのツール開発
雑に使える砂場
作った環境
デフォルトで入れてあるツール
Golang(1.19)
Git
NVM/yarn
その他標準的なdebianのツール
port
9000だけ開けてある。必要に応じてdevcontainer.jsonを編集すれば開けられる。
Golang用のpackages
dlv
golangci-lint
golint
gomodifytags
go-outline
gopkgs
goplay
gopls
gotests
impl
revive
staticcheck
VSCode設定
拡張
golang.Go
GitHub.copilot
esbenp.prettier-vscode
Project
server.goをエントリーポイントにしてある
VSCodeでのDebug
vscode-remote-try-go/README.md at main · microsoft/vscode-remote-try-go
Debugging in Visual Studio Code
ミドルウェアを追加して環境を作る場合
Using Images, Dockerfiles, and Docker Compose
docker-compose.ymlを使う想定
vscode Dev Containers golang